package main

import "fmt"

var m map[int]string

func mmp()  {
	m1 := make(map[int]string)

	m1[1] = "a"
	m1[2] = "b"
	m1[3] = "c"

	//遍历
	printMap(m1)

	//查看元素是否存在
	c, ok := m1 [2]
	if(ok){
		fmt.Println("2的值为：", c)
	}else{
		fmt.Println("2的值不存在")
	}

	//删除元素
	delete(m1, 2)
	d, ok := m1 [2]
	if(ok){
		fmt.Println("2的值为：", d)
	}else{
		fmt.Println("2的值不存在")
	}

}

func printMap(m map[int]string)  {
	for a := range m {
		fmt.Println("key:%d value:%s", a, m[a])
	}
}